package searchtab.search;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;

import searchtab.search.textfile.TextEditorSearcher;
import searchtab.views.SearchTabView;

public class SearcherEngine implements ModifyListener {

    private ISearcher currentSeacher;

    public SearcherEngine() {
    }

    public void setView(SearchTabView searchTabView) {
        currentSeacher = new TextEditorSearcher(searchTabView);
    }

    public void goToNextMatch() {
        currentSeacher.goToNextMatch();
    }

    public void goToPreviousMatch() {
        currentSeacher.goToPreviousMatch();
    }

    public void markResults() {
        currentSeacher.markResults();
    }

    public void unmarkResults() {
        currentSeacher.unmarkResults();
    }

    public void changeMatchCaseOption() {
        currentSeacher.runSearch();
    }

    public TextEditorSearcher getCurrentSeacher() {
        return (TextEditorSearcher) currentSeacher;
    }

    public void modifyText(ModifyEvent modifyEvent) {
        currentSeacher.runSearch();
    }

}
